package com.hsb.seckill.rabbitmq;

import com.hsb.seckill.vo.SeckillMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 消息发送者
 */
@Service
@Slf4j
public class MQSender {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    //发送商品秒杀消息
    public void sendSeckillMessage(String msg){
        //log.info("发送秒杀商品消息："+msg);
        rabbitTemplate.convertAndSend("seckillExchange","seckill.doSeckill",msg);
    }

    ////hello模式
    //public void sendHello(Object msg){
    //    log.info("发送消息："+msg);
    //    rabbitTemplate.convertAndSend(msg);
    //}
    //
    ////fanout模式
    //public void sendFanout(Object msg){
    //    log.info("发送消息："+msg);
    //    rabbitTemplate.convertAndSend("fanoutExchange","",msg);
    //}
    //
    ////direct模式
    //public void sendDirect01(Object msg){
    //    log.info("发送red消息："+msg);
    //    rabbitTemplate.convertAndSend("directExchange","queue.red",msg);
    //}
    //public void sendDirect02(Object msg){
    //    log.info("发送green消息："+msg);
    //    rabbitTemplate.convertAndSend("directExchange","queue.green",msg);
    //}
    //
    ////topic模式
    //public void sendTopic01(Object msg){
    //    log.info("发送消息："+msg);
    //    rabbitTemplate.convertAndSend("topicExchange","queue.red.message",msg);
    //}
    //public void sendTopic02(Object msg){
    //    log.info("发送消息："+msg);
    //    rabbitTemplate.convertAndSend("topicExchange","message.queue.green.abc",msg);
    //}
}


